<html>
<head>
	<link href="<?php echo _get_cfg_path('admin_css')?>base.css" rel="stylesheet" type="text/css" />
	<link href="<?php echo _get_cfg_path('admin_css')?>common.css" rel="stylesheet" type="text/css" />
	<link href="<?php echo _get_cfg_path('admin_css')?>main.css" rel="stylesheet">
    <link href="<?php echo _get_cfg_path('admin_css')?>right.css" rel="stylesheet">
    <link href="<?php echo _get_cfg_path('admin_css')?>index.css" rel="stylesheet">
    <link href="<?php echo _get_cfg_path('lib')?>uploadify/uploadify.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="<?php echo _get_cfg_path('admin_css')?>../ueditor1_4_3/ueditor.config.js"></script>
<script type="text/javascript" src="<?php echo _get_cfg_path('admin_css')?>../ueditor1_4_3/ueditor.all.js"></script>
</head>

<body>

<div class="right_con common adduser">

	<a href="/admin/advisory" class="topBtn">返回列表</a>
	<?php echo validation_errors('<div class="valid_error">', '</div>');?>
	<form action="/admin/advisory/save<?php if( !empty($info['id']) ) echo '?id='. _get_key_val( $info['id'] ); ?>" method="post">

		<table class="addTable">
			<tbody>
		        <tr>
		            <td height="25" align="right"><span class="tips">*</span> 资讯标题：</td>
		            <td align="left" class="padL10"><input type="text" name="title" class="advisory_input" value="<?php if( !empty($info['title']) ) echo $info['title']; ?>" /></td>
		        </tr>
		        <tr>
		            <td height="25" align="right"><span class="tips">*</span> 类型：</td>
		            <td align="left" class="padL10">
		              <select name="type">
                        <option value="0">请选择</option>
                        <option value="1" <?php if ($info['type']&&$info['type']==1):?>selected="selected"<?php endif;?>>时尚资讯</option>
                        <option value="2" <?php if ($info['type']&&$info['type']==2):?>selected="selected"<?php endif;?>>摄影基地</option>
                      </select>
		            </td>
		        </tr>
		        <tr>
		            <td height="25" align="right"><span class="tips">*</span> <span class="advisory_tag_label"><?php if ($info['tag'] && $info['type']==2) echo '城市';else echo '资讯标签';?></span>：</td>
		            <td align="left" class="padL10"><input type="text" name="tag" class="advisory_input" value="<?php if( !empty($info['tag']) ) echo $info['tag']; ?>" /></td>
		        </tr>
		        <tr>
		            <td height="25" align="right"><span class="tips">*</span> 资讯图片：</td>
		            <td align="left" class="padL10"><div id="previews" class="drsMoveHandle">
	                        <img id="show_img" width="100" border=0 src='<?php if( !empty($info['advisory_img']) ) echo  _get_image_url($info['advisory_img']);?>'>
	                    </div>
	                    <div class="f_note">
	                        <input type="hidden"  name="advisory_img" id="img" value="<?php if( !empty($info['advisory_img']) ) echo $info['advisory_img']; else echo 'http://'; ?>">
	                        <em><i class="icoPro16"></i>支持JPEG/PNG，上传图片大小不能超过1M</em>
	                        <div class="file_but">
	                            <input id="img_upload" name="img_upload" value="选择图片" class="inp_file" type="file">
	                        </div>
	                    </div>
	                </td>
		        </tr>
		        <tr>
		            <td height="25" align="right"><span class="tips">*</span> 内容：</td>
		            <td align="left" class="padL10"><textarea type="text" name="content" cols="50" rows="6"><?php if( !empty($info['content']) ) echo $info['content']; ?></textarea></td>
		        </tr>
		        <tr>
		            <td height="25" align="right"><span class="tips">*</span> 资讯日期：</td>
		            <td align="left" class="padL10"><input class="advisory_input" type="text" name="advisory_date" value="<?php if( !empty($info['advisory_date']) ) echo date('Y-m-d',$info['advisory_date']); else echo date('Y-m-d',time()); ?>" readonly="readonly" onclick="WdatePicker()"  /></td>
		        </tr>
		        <tr>
                  <td valign="top" align="right"> 资讯详情：</td>
                  <td><div id="myEditor" style="width:700px;margin:5px 0;"></div>
                      <script type="text/javascript">
                         var ue = UE.getEditor('myEditor');
                         <?php if(!empty($info)){?>
                         ue.addListener("ready", function () {
                             // editor准备好之后才可以使用
                             ue.setContent('<?php echo htmlspecialchars_decode($info['advisory_desc'])?>');
                         });
                         <?php }?>
                      </script>
                  </td>
                </tr>
				<tr>
		            <td></td>
		            <td class="padL10"><input type="submit" class="sub" value="提交"></td>
		        </tr>
		    </tbody>
		</table>
	</form>
</div>
<script type="text/javascript" src="<?php echo _get_cfg_path('lib')?>My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<?php echo _get_cfg_path('js')?>jquery-1.11.2.min.js"></script>
<script src="<?php echo _get_cfg_path('lib')?>uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<script type="text/javascript">
<?php $timestamp = $this->timestamp;?>
$(function() {
    $('#img_upload').uploadify({
      'formData'     : {
        'timestamp' : '<?php echo $timestamp;?>',
        'token'     : '<?php echo md5($this->config->item('encryption_key') . $timestamp );?>',
        'type' : 'img',
        'uid' : 0
      },
      'auto':true,
      //'buttonClass':'inp_btn',
      'fileSizeLimit' : '1024KB',
      'buttonText':'选择照片',
      'fileTypeExts': '*.jpg;*.png;*.jpeg',
      //'buttonImage' : '{$js_url}uploadify/button.png',
      'swf'      : '<?php echo _get_cfg_path("lib")?>uploadify/uploadify.swf',
      'uploader' : '/public/upload/uploadimg',
      'onUploadSuccess' : function(file, data, response) {
        if (!data){
         alert('上传失败');
         return;
        }
        data = data.split('|');
        if (data[0] == 100){
          $('#img').nextAll('em').html('<i class="icoErr16"></i>'+data[1]);
        }else if(data[0] == 200 && data[1]!=''){
          var imgpath=data[1];
          $('#img').val(imgpath);
          $('#img').nextAll('em').html('<i class="icoCor16"></i>');
          $('#show_img').attr('src','/'+imgpath);
        }
      }

    });

    //摄影基地城市输入
    $("select[name='type']").change(function(){
        var type = $(this).val();
        if(type == 1)
        {
            $(".advisory_tag_label").text('资讯标签');
        }
        else if(type == 2)
        {
        	$(".advisory_tag_label").text('城市');
        }
    });
});
</script>
</body>
</html>